#include "MeshFilter.h"
#include "Transform.h"
#include "GameObject.h"


__ImplementClass(MeshFilter, std::string("MeshFilter"), Component);


MeshFilter::MeshFilter()
{
    m_pMeshObject = NULL;
}

MeshFilter::~MeshFilter()
{

}

void MeshFilter::Update(float delta)
{

}

void MeshFilter::setMeshObject(MeshObject* pMeshObject)
{
	m_pMeshObject = pMeshObject;
	Entity* pEntity = m_pMeshObject->getEntity();
	GameObject* pGameObject = (GameObject*)getParent();
	if (pGameObject)
	{
		Transform* pTransform = (Transform*)pGameObject->FindComponent("Transform");
		if (pTransform)
		{
			SceneManager* pSceneManager = Root::getSingletonPtr()->getSceneManager("DummyScene");
			if (pSceneManager)
			{
				SceneNode* pSceneNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
				pSceneNode->attachObject(m_pMeshObject->getEntity());
				pTransform->Attach(pSceneNode,Transform::TRANSFORM_SCENE_NODE);
			}

		}
	}

}